package com.picture;


import javax.swing.*;
import java.awt.*;

@SuppressWarnings({"all"})
public class Test_1 extends  JFrame {
    //定义一个面板
    private MyPanel_2 mp=null;
    //主函数
    public static void main(String[] args) {
        new Test_1();
    }
    //初始化面板
    public Test_1(){
        mp=new MyPanel_2();//new画笔
        this.add(mp);
        this.setSize(1080,680);//设置画板大小
        this.setVisible(true);//绘图可视化
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//差了程序就退出

    }
}

class MyPanel_2 extends JPanel{
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        //添加图片
//        Image image = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/gold.png"));
//        g.drawImage(image,200,200,300,300,this);
//        Image image1 = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/hh.png"));
    //    g.drawImage(image1,0,0,1080,680,this);
//        System.out.println("666!");
//        g.setColor(Color.blue);
//        g.draw3DRect(300,300,200,60,true);
//        g.setColor(Color.green);
//        g.draw3DRect(600,300,200,60,true);
        //设置字体
        g.setFont(new Font("楷书",Font.BOLD,50));
        g.setColor(Color.red);
        g.drawString("新年快乐",350,300);
        g.fill3DRect(20,30,200,100,true);

    }
}
